/*
 *  Copyright (C) 2010 Zubanov Dmitry
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


/**
 *
 * @author Zubanov Dmitry aka javadimon, zubanov@gmail.com
 * Omsk, Russia, created 22.09.2010
 * (C) Copyright by Zubanov Dmitry
 */

package org.jssdb.core.filesystem;

import java.io.File;
import java.io.Serializable;
import org.jssdb.core.DBProperties;
import org.jssdb.core.ram.RamHandler;

public class FileContainer implements Serializable{
    
    private Object storedObject;
    private long id, lastModified;
    private String className, fileName;

    public FileContainer(long id, long lastModified, String className,
            String fileName, Object obj){
        this.id = id;
        this.lastModified = lastModified;
        this.className = className;
        this.fileName = fileName;
        storedObject = obj;
    }
    
    public void writeFile(){
        RamHandler.getInstance().updateObject(id, storedObject);
        String filePath = DBProperties.getInstance().getPathToDB() + className + File.separator + fileName;
        File f = new File(filePath);
        if(f.isFile()){
            f.setLastModified(lastModified);
        }
    }
}
